$(function(){
	var $body = $(document.body);;
	var $bottomTools = $('.bottom_tools');
		$(window).scroll(function () {
			var scrollHeight = $(document).height();
			var scrollTop = $(window).scrollTop();
			var $footerHeight = $('.page-footer').outerHeight(true);
			var $windowHeight = $(window).innerHeight();
			scrollTop > 1 ? $(".scrollUp").fadeIn(0).css("display","block") : $(".scrollUp").fadeOut(0);			
			$bottomTools.css("bottom", scrollHeight - scrollTop - $footerHeight > $windowHeight ? 130 : $windowHeight + scrollTop + $footerHeight + 130 - scrollHeight);
		});
		$('.scrollUp').click(function (e) {
			e.preventDefault();
			$('html,body').animate({ scrollTop:0});
		});
		
});